home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Music Architecture / Embedding Instruments / BigEasy / BigEasyControls.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-21  |  6.8 KB  |  216 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        BigEasyControls.h
  3.  
  4.     Written by:    dvb
  5.  
  6.     Copyright:    © 1990-1991 by Apple Computer, Inc., all rights reserved.
  7.  
  8.     This file is used in these builds: Warhol
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <6>     4/13/92    dvb        #ifdef for multiple inclusions.
  13.          <5>      4/3/92    dvb        Oh, structure names should start with upper case. What was I
  14.                                     thinking of, anyway?
  15.          <4>     1/20/92    dvb        Latest BigEasy revs.
  16.          <3>    12/19/91    JB        removing think 4.0 code
  17.          <2>     5/28/91    JB        Added prototypes for BigEasy Proc Ptrs
  18.          <3>      8/3/90    dvb        Smarter rectangle changes
  19.          <2>     7/31/90    dvb        Update for control-list-handles
  20.  
  21.     To Do:
  22. */
  23.  
  24. /*
  25.   * file: BigEasyControls.h
  26.   *
  27.   * started 25 May 1990 12:07:24 Friday at 310 Nobel
  28.   * 
  29.   * david van brink
  30.   *
  31.   */
  32.  
  33. #ifndef _BigEasyControls_
  34. #define _BigEasyControls_
  35.  
  36. /************************************
  37. * types
  38. ************************************/
  39.  
  40. /*
  41.   * void NewProc(easyControlPtr ec);
  42.   * void DisposeProc(easyControlPtr ec);
  43.   * void TrackProc(easyControlPtr ec,Point p);
  44.   */
  45.  
  46. typedef void (*becNewProcPtr)(struct easyControlRecord *ec);        
  47. typedef void (*becDisposeProcPtr)(struct easyControlRecord *ec);        
  48. typedef void (*becDrawProcPtr)(struct easyControlRecord *ec);    
  49. typedef void (*becHitTestProcPtr)(struct easyControlRecord *ec,Point p);
  50. typedef void (*becTrackProcPtr)(struct easyControlRecord *ec,Point p,short *result,short mods);    
  51. typedef void (*becKeyProcPtr)(struct easyControlRecord *ec,short key,short mods,Boolean *tookKey);        
  52. typedef void (*becSetValueProcPtr)(struct easyControlRecord *ec,long value);    
  53. typedef void (*becIdleProcPtr)(struct easyControlRecord *ec,long *ref);        
  54. typedef void (*becDrawValueProcPtr)(struct easyControlRecord *ec);        /* Function Pointer */
  55.  
  56. typedef void (*becActionProcPtr)(long value,long refcon);        
  57. typedef void (*becInitActionProcPtr)(long value,long refcon);        
  58. typedef void (*becDoneActionProcPtr)(long value,long refcon);        
  59. typedef void (*becValueProcPtr)(struct easyControlRecord **ec);        
  60.  
  61. typedef struct
  62.     {
  63.     becNewProcPtr newProc;
  64.     becDisposeProcPtr disposeProc;
  65.     becDrawProcPtr drawProc;
  66.     becHitTestProcPtr hitTestProc;
  67.     becTrackProcPtr trackProc;
  68.     becKeyProcPtr keyProc;
  69.     becSetValueProcPtr setValueProc;
  70.     becIdleProcPtr idleProc;
  71.     becDrawValueProcPtr drawValueProc;
  72.     } easyControlType;
  73.  
  74. #ifdef privateEasyControls
  75. /*
  76.   * This should only be included by control manager and controls
  77.   */
  78.  
  79. typedef struct easyControlRecord
  80.     {
  81.     easyControlType *type;
  82.     Rect rect;
  83.     long refcon;
  84.     long id;                /* Sort of another refcon, used to uniquely identify each control */
  85.     long variation;
  86.     long flags;                /* Common states, like "active/inactive"                    */
  87.     long value;            /* Could be a pointer or handle to complex value            */
  88.     void *state;            /* For internal use of the type                            */
  89.     void *style;            /* Shared style information, depending on type                */
  90.     short color[6];            /* Defines the color appearance of the control, in 555 colors    */
  91.     becActionProcPtr actionProc;        /* while dragging                */
  92.     becInitActionProcPtr initActionProc;        /* called once before dragging                */
  93.     becDoneActionProcPtr doneActionProc;        /* called once after dragging                */
  94.     becValueProcPtr valueProc;            /* called when value changes        */
  95.     /* CFP keyProc;            /* to process key presses        */
  96.     long low,high;            /* range of control                */
  97.     struct easyControlRecord **prev;
  98.     struct easyControlRecord **next;
  99.     struct easyControlListRecord **list;
  100.     } easyControlRecord,*easyControlPtr,**easyControl;
  101. /* #define  easyControlPtr easyControlRecord * */
  102.  
  103. enum                                        /* flags field of easyControl */
  104.     {
  105.     easyControlActive = 1,
  106.     easyControlBack = 2,                    /* set when the owner window is background */
  107.     easyControlTracking = 4,                    /* set while the control is tracking */
  108.     easyControlSetValue = 8,                    /* set if redraw is for "setvalue" */
  109.     easyControlMoved = 16            /* set when the control has moved, cleared by cdef */
  110.     };
  111.  
  112. typedef struct easyControlListRecord
  113.     {
  114.     easyControl firstControl;
  115.     easyControl selectedControl;
  116.     easyControl nextSelectedControl;        /* if nothing selected, this may specify what "tab" gets to */
  117.     short textFont;
  118.     short textFace;
  119.     short textSize;
  120.     WindowPtr ownerWindow;                    /* the window these controls are attached to */
  121.     long refcon;                            /* for the application */
  122.     long idleRef;
  123.     long nextIdle;
  124.     long ticksPerIdle;
  125.     long controlCount;
  126.     } easyControlListRecord, *easyControlListPtr, **easyControlList;
  127.  
  128. #else
  129.  
  130. typedef struct {
  131.     long dummy;
  132.     } **easyControl;
  133.  
  134. typedef struct {
  135.     long dummy;
  136.     } **easyControlList;
  137.  
  138. #endif
  139.  
  140.  
  141. typedef struct
  142.     {
  143.     easyControl whichControl;
  144.     Boolean tracked;
  145.     long value;
  146.     long refcon;
  147.     long id;
  148.     } controlClickResult;
  149.  
  150. enum            /* colors in a control */
  151.     {
  152.     controlFrame = 0,
  153.     controlBackground,
  154.     controlPart1,
  155.     controlPart2
  156.     };
  157.  
  158.  
  159. /************************************
  160. * Macros
  161. ************************************/
  162. #define AsFloat(x) ( *((float *)(& x)))            /* interpret a var's bits as if they was floatin' pt */
  163. #define PackColor555(r,g,b) (( (r)>>11<<10) | ( (g)>>11<<5) | ( (b)>>11))
  164.  
  165. #define EasyControl easyControl
  166. #define EasyControlList easyControlList
  167. #define ControlClickResult controlClickResult
  168.  
  169. /************************************
  170. * prototypes
  171. ************************************/
  172.  
  173. easyControlList NewEasyControlList(WindowPtr w, long refcon);
  174. void DisposeEasyControlList(easyControlList list);
  175.  
  176. easyControl NewEasyControl(easyControlType *,Rect *,long variation, 
  177.         void *style,long refcon,long id, long value,easyControlList list);
  178. void DisposeEasyControl(easyControl, easyControlList list);
  179.  
  180. void SetEasyControlRange(easyControl ech,long low,long high);
  181. void SetEasyControlValueProc(easyControl ech, becValueProcPtr valueProc);
  182. void SetEasyControlActionProc(easyControl ech, becActionProcPtr actionProc);
  183. void SetEasyControlInitActionProc(easyControl ech, becInitActionProcPtr initActionProc);
  184. void SetEasyControlDoneActionProc(easyControl ech, becDoneActionProcPtr doneActionProc);
  185.  
  186. void SetEasyControlValue(easyControl ech,long value);
  187. long GetEasyControlValue(easyControl);
  188. long GetEasyControlRefcon(easyControl);
  189. long GetEasyControlID(easyControl);
  190. void GetEasyControlRect(easyControl,Rect *);
  191. void SetEasyControlRect(easyControl,Rect *);
  192.  
  193. void DrawEasyControlList(easyControlList list);
  194. easyControl ClickEasyControlList(easyControlList list,Point p,
  195.         controlClickResult *,short mods);
  196. void KeyEasyControlList(easyControlList list,short key,short mods,controlClickResult *ccr);
  197. void ActivateEasyControlList(easyControlList list);
  198. void DeactivateEasyControlList(easyControlList list);
  199.  
  200. void GetEasyControlColors(easyControl,short *colors);
  201. void SetEasyControlColors(easyControl,short *colors);
  202. void IdleEasyControlList(easyControlList list);
  203.  
  204. void Fore555(short);
  205. void Fore555Light(short);
  206. void Fore555Dark(short);
  207. void Fore555Contrast(short);
  208. unsigned short Replicate555(unsigned short);
  209. void Color555(short,RGBColor *c);
  210.  
  211. void RaisedRect(Rect *r,short x);
  212. void LoweredRect(Rect *r,short x);
  213.  
  214.  
  215. #endif _BigEasyControls_
  216.